# # courses/tasks.py
# from celery.schedules import crontab
# from django.conf.global_settings import DEFAULT_FROM_EMAIL
#
# from celery import shared_task
# from django.core.mail import send_mail
#
# from HopeIESystem.celery import app
# from .models import SelectionInfo
# from datetime import datetime, timedelta
#
#
# @shared_task
# def remind_user_to_select_course():
#     print("remind_user_to_select_course")
#     # 检查每一项is_finish=False
#     # selections = SelectionInfo.objects.filter(
#     #     is_finish=False
#     # )
#     # for selection in selections:
#     #     # 这里简化处理，实际使用时应配置邮件服务器等信息
#     #     if has_permission_choose(selection):
#     #         send_mail(
#     #             '课程选择提醒',
#     #             f'您好，{selection.author_name}，您的课程选择已开始，请尽快登录系统进行选择。',
#     #             DEFAULT_FROM_EMAIL,  # 发件人邮箱
#     #             [selection.author_account],  # 收件人列表，这里假设author_account是邮箱地址
#     #             fail_silently=False,
#     #         )
#         # 如果邮件发送成功，你可能还想更新数据库标记为已提醒或已处理
#
#
# def has_permission_choose(selectionInfo):
#     # 获取当前用户的选课信息
#
#     id = selectionInfo.id
#     # 获取当前id的上一个id的selectionInfo
#     if id == 1:
#         previous_selectionInfo = selectionInfo
#     else:
#         previous_selectionInfo = SelectionInfo.objects.get(id=id - 1)
#     # 获取当前时间如果不在时间段内不得选课
#     current_time = datetime.now()
#     if previous_selectionInfo.is_finish and current_time < selectionInfo.end_time:
#         # 上一位已经选课结束且没有到达你的选课结束时间，您可以提前选课
#         return True
#     elif not previous_selectionInfo.is_finish and selectionInfo.end_time > current_time > selectionInfo.start_time:
#         # 上一位没有选课，你可以先选课
#         return True
#     return False
#
#
# app.conf.beat_schedule = {
#     'add-every-30-seconds': {
#         'task': 'HopeIESystem.tasks.remind_user_to_select_course',
#         'schedule': timedelta(seconds=3),
#         'args': ()
#     },
# }
from datetime import timedelta

from celery import shared_task
from time import sleep

from celery.schedules import crontab

from HopeIESystem.celery import app


@shared_task
def schedule_task():
    print("和     是的是的")

